#ifndef _LED_H_
#define _LED_H_

#include <Arduino.h>

#define ON 1
#define OFF 0

/*
 * 数据格式为开始的对齐帧3字节，后为一字节数据加两字节亮度的23组，最后一字节的亮度
 */

class LED{

  public:
  void begin();
  void end();
  void write();
  void color(unsigned short mode);
  void battery(unsigned char bat_cap);
  void second(u8 dat);
  void time(unsigned char time_hour,unsigned char time_min);
  void power(bool mode);
  u8 color_mode_buf;
  u8 color_mode; //颜色模式  0：左蓝右紫 1：左紫右蓝  2：自选颜色 
  u8 color_choose_mode; //颜色模式  0：固定 1：随机 
  u8 color_mix;//调色紫色占比
  s8 color_mix_buf;

  bool bat_show_flg;

  u8 last_time_data[4] = {255,255,255,255};

  private:
  const u8 uart_head[3]={0x98,0x08,0x31};
  const u8 F5x8[10][5] =    
  {
    0x7E, 0x81, 0x81, 0x81, 0x7E,// 0
    0x00, 0x82, 0xfF, 0x80, 0x00,// 1
    0x82, 0xc1, 0xa1, 0x91, 0x8e,// 2
    0x41, 0x81, 0x89, 0x95, 0x63,// 3
    0x3e, 0x20, 0x20, 0xfF, 0x20,// 4
    0x47, 0x89, 0x89, 0x89, 0x71,// 5
    0x7C, 0x92, 0x91, 0x91, 0x60,// 6
    0x01, 0x01, 0xf9, 0x05, 0x03,// 7
    0x76, 0x89, 0x89, 0x89, 0x76,// 8
    0x06, 0x89, 0x89, 0x49, 0x3E,// 9
  };
  u8 led_dat_gram[23];
  u8 led_color_gram[46];
  u8 led_light_gram;
  s8 second_num = 0;
  u8 second_buf = 0;
  bool second_mode = 1;
  u8 last_second = 255;
  bool change_flg = 0;
  u8 stay_flg = 0;

  
  bool last_time_flg[4] = {0,0,0,0};
  u8 time_change_cont = 1;

};

extern LED led;

#endif  
